//
//  ViewController.m
//  11202
//
//  Created by student on 16/3/3.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) NSArray *list;
@property (weak, nonatomic) IBOutlet UITableView *tableview;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"heroes" ofType:@"plist"];
    NSArray *herolist = [NSArray arrayWithContentsOfFile:path];
    self.list = herolist;
    self.tableview.rowHeight = 60;
//    NSDictionary *item = self.list[1];
//    NSString *imgname = item[@"icon"];
//    NSString *imgtxt = item[@"name"];
//    NSString *imgdescribe = item[@"intro"];
////    cell.imageView.image = [UIImage imageNamed:imgname];
////    cell.textLabel.text = imgtxt;
////    cell.detailTextLabel.text = imgdescribe;
//    NSLog(@"%@%@%@",imgname,imgtxt,imgdescribe);
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.list.count;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
    NSDictionary *item = self.list[indexPath.row];
    NSString *imgname = item[@"icon"];
    NSString *imgtxt = item[@"name"];
    NSString *imgdescribe = item[@"intro"];
    cell.imageView.image = [UIImage imageNamed:imgname];
    cell.textLabel.text = imgtxt;
    cell.detailTextLabel.text = imgdescribe;
    NSLog(@"%@%@%@",imgname,imgtxt,imgdescribe);
    return cell;
}



@end
